import { baseRequestClient, requestClient } from '#/api/request';

export namespace ProductRecpt {
  export interface Params {
    attr1: null;
  }
  export interface Row {
    searchValue: null;
    createBy: string;
    createTime: Date;
    updateBy: string;
    updateTime: Date;
    remark: string;
    params: Params;
    recptId: number;
    recptCode: string;
    recptName: null | string;
    workorderId: null | number;
    workorderCode: null | string;
    workorderName: null | string;
    itemId: null | number;
    itemCode: null | string;
    itemName: null | string;
    specification: null;
    unitOfMeasure: null | string;
    unitName: null | string;
    recptDate: Date;
    status: string;
    attr2: null;
    attr3: number;
    attr4: number;
    attr1: boolean | null | string;
  }
  export interface GetListParams {
    pageNum: number;
    pageSize: number;
  }
  export interface GetListReturn {
    total: number;
    rows: Row[];
    code: number;
    msg: string;
  }
}

// 获取列表
export const getProductRecptTableList = (params: ProductRecpt.GetListParams) =>
  requestClient.get<ProductRecpt.GetListReturn>('/mes/wm/productrecpt/list', {
    params,
  });
// 增加产品入库单
export const addProductRecpt = (data: ProductRecpt.Row) =>
  requestClient.post<ProductRecpt.GetListReturn>('/mes/wm/productrecpt', data);

// 删除产品入库单
export const deleteProductRecpt = (id: string) =>
  requestClient.delete<ProductRecpt.GetListReturn>(
    `/mes/wm/productrecpt/${id}`,
  );

// 修改产品入库单
export const updateProductRecpt = (data: ProductRecpt.Row) =>
  requestClient.put<ProductRecpt.GetListReturn>('/mes/wm/productrecpt', data);

export const getProductRecptCode = () =>
  baseRequestClient.get<any>('/system/autocode/get/PRODUCTRECPT_CODE');
